trigger NSOpportunityAttchmentType on Opportunity_Attachments_Classification__c (after insert,after update)
{
Set<Id> setoppid=new Set<Id>();
ID RecTypeID = RecordTypeHelper.GetRecordTypeID('Opportunity','Contract');
for(Opportunity_Attachments_Classification__c oppattach:trigger.new)
{
setoppid.add(oppattach.Opportunity__c);
}
List<Opportunity> lstopportunity=new List<Opportunity>();
for(Opportunity opp:[Select Id,Has_NMP__c,(Select Opportunity__c,Attachment_Type__c,AttachmentId__c From Opportunity_Attachments_Classification__r where id in :trigger.new) From Opportunity where Id in:setoppid and RecordTypeId=:RecTypeID])
{
List<Opportunity_Attachments_Classification__c> lstattachment=opp.Opportunity_Attachments_Classification__r;
for(Opportunity_Attachments_Classification__c oppattach:lstattachment)
{
 system.debug('testing'+oppattach.Attachment_Type__c);
 if(oppattach.Attachment_Type__c=='Discount Approval (NMP/MYA)')
 {
 opp.Has_NMP__c=True;
 lstopportunity.add(opp);
 }
}
update lstopportunity;
system.debug('testinglstopportunity'+lstopportunity);
}
}